const mongoose = require('mongoose');

const serviceSchema = new mongoose.Schema({
    name: {
        type: String,
        required: true,
        trim: true
    },
    category: {
        type: String,
        required: true,
        enum: ['面部护理', '身体按摩', '足疗', 'SPA', '美甲', '美发', '其他']
    },
    price: {
        type: Number,
        required: true,
        min: 0
    },
    duration: {
        type: Number,
        required: true,
        min: 1,
        comment: '服务时长（分钟）'
    },
    description: {
        type: String,
        trim: true
    },
    image: {
        type: String,
        default: ''
    },
    status: {
        type: Boolean,
        default: true,
        comment: '服务状态：true-可用，false-不可用'
    },
    createTime: {
        type: Date,
        default: Date.now
    },
    updateTime: {
        type: Date,
        default: Date.now
    }
});

// 更新时间中间件
serviceSchema.pre('save', function (next) {
    this.updateTime = new Date();
    next();
});

module.exports = mongoose.model('Service', serviceSchema); 